package com.item.springsecurity.builder;

/**
 * _______                             __________
 * \      \   _______  __ ___________  \______   \__ __  ____
 * /   |   \_/ __ \  \/ // __ \_  __ \  |    |  _/  |  \/ ___\
 * /    |    \  ___/\   /\  ___/|  | \/  |    |   \  |  / /_/  >
 * \____|__  /\___  >\_/  \___  >__|     |______  /____/\___  /
 * \/     \/          \/                \/     /_____/
 *
 * @Auther: wangdong
 * @Description: TODO <p>Builder模式，灵活赋值创建与赋值</p>
 * @Date: 2019/4/25 14:51
 * @Version 1.0
 */
public class Student {
    private int id;

    private String name;

    private int age;

    private long createDate;

    public Student(Builder builder) {
        this.id = builder.id;
        this.name = builder.name;
        this.age = builder.age;
        this.createDate = builder.createDate;
    }


    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public long getCreateDate() {
        return createDate;
    }

     static class Builder{
        private int id;

        private String name;

        private int age;

        private long createDate;



        public Builder setId(int id) {
            this.id = id;
            return this;
        }

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public Builder setAge(int age) {
            this.age = age;
            return this;
        }

        public Builder setCreateDate(long createDate) {
            this.createDate = createDate;
            return this;
        }

        public Student builder(){
            return new Student(this);
        }

    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", createDate=" + createDate +
                '}';
    }
}
